feat(dvc): expose dynamic channel accessors#1368
Conversation
There was a problem hiding this comment.
Thank you!
This API feels a bit implementation-shaped to me. The use case we want to support is "given a DVC channel id, recover my typed processor so I can call its domain-specific API mutably." But exposing DynamicChannel directly seems to expose the current storage and lifecycle wrapper as part of the public contract.
Just thinking out loud, but maybe we could make the public API narrower and more intention-shaped instead, e.g. typed processor accessors on DrdynvcClient / DrdynvcServer, while keeping the channel wrapper types private?
Also, the new DvcClientProcessor bound seems inconsistent with registration: client APIs still accept T: DvcProcessor and listeners return Box<dyn DvcProcessor>, but downcasting now requires T: DvcClientProcessor. Maybe registration/listener APIs should also use DvcClientProcessor, or the downcast bound should remain DvcProcessor?
Thanks, that makes sense to me. I exposed
Agreed, so the API looks like
Thanks for pointing out, will be resolved in this PR. |
9f2fd45 to
9d2a0d3
Compare
|
Benoît Cortier (@CBenoit) I reserve my perspective after I tried to modify the client I think there is a valid public use case for a channel handle: callers sometimes need the channel id and the typed processor together. Splitting that into separate APIs such as That said, I agree with the concern that exposing the current channel wrapper exposes implementation shape:
The storage itself is not exposed while the fields stay private, but the current wrapper still exposes lifecycle/storage shape through the public type and the downcast-based accessor methods. Also, mutable processor access is the reason this PR exists, so some controlled mutable access to the underlying processor is unavoidable. I mentioned the original need here: #1137 (comment) Maybe the better API is to keep pub struct DvcAccessor<'a, T: DvcProcessor> {
channel_id: u32,
processor: &'a T,
}
pub struct DvcAccessorMut<'a, T: DvcProcessor> {
channel_id: u32,
processor: &'a mut T,
}Then |
dad3bed to
9cfe549
Compare
Add mutable dynamic channel lookup APIs for drdynvc server. Signed-off-by: uchouT <i@uchout.moe>
Benoît Cortier (CBenoit)
left a comment
There was a problem hiding this comment.
LGTM! I think you converged towards a good API, let’s merge! 💯
There was a problem hiding this comment.
Pull request overview
This PR extends the ironrdp-dvc public API to allow mutable access to dynamic channel processors by channel ID (primarily for drdynvc server-side channels), enabling upper-layer DVC processors to work with &mut self access patterns (as needed by URBDRC work referenced in #1365).
Changes:
- Added
DynamicChannelRef/DynamicChannelMutwrapper types to expose(channel_id, processor ref)pairs safely. - Added
DrdynvcServer::{dvc_by_id, dvc_by_id_mut}for typed, state-checked dynamic channel processor lookup by ID. - Added
DrdynvcClient::get_dvc_by_channel_id_mutto allow mutable access to a client-sideDynamicVirtualChannelby channel ID.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/ironrdp-dvc/src/server.rs | Adds typed dynamic-channel processor lookup (shared/mutable) gated on Opened state. |
| crates/ironrdp-dvc/src/lib.rs | Introduces public wrapper types for returning (channel_id, processor) references from lookups. |
| crates/ironrdp-dvc/src/client.rs | Exposes a mutable lookup accessor for active client-side dynamic channels by channel ID. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
985d353
into
Devolutions:master
Add mutable dynamic channel lookup APIs for drdynvc client / server, so that we can use the public API with signature
&mut selfin dvc processor, such asUrbdrcDeviceClientandUrbdrcControlClientin #1365